package com.xxxtentacion.mr.exam.step2;

import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

import java.io.IOException;
/**
 * @author urboifrdscks!
 */
public class ExamMapper extends Mapper<LongWritable, Text,ExamBean, NullWritable> {
    final ExamBean bean = new ExamBean();

    @Override
    protected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {
/*
        final String[] field = value.toString().split("\\t");
        for (String s : field) {
            bean.setKey(Integer.parseInt(s));
            context.write(bean,NullWritable.get());
        }
*/

        bean.setKey(Integer.parseInt(value.toString()));
        context.write(bean, NullWritable.get());


/*
        // 1.去除所有非ASCII字符
        text = text.replaceAll("[^\\p{ASCII}]","");
        // 2.去除多余的空格
        text = text.replaceAll("\\s+"," ");
        // 3.清除ASCII控制字符
        text = text.replaceAll("[\\p{Cntrl}]","");
        // 4.清除非打印字符
        text = text.replaceAll("[^\\p{Print}]","");

*/

    }
}

